//
//  TMGAccountSafeViewController.m
//  TMGold
//
//  Created by Mac on 2017/12/8.
//  Copyright © 2017年 tangmu. All rights reserved.
//

#import "TMGAccountSafeViewController.h"
#import "TMGChangePwdViewController.h"
#import "TMGEleSignViewController.h"
#import "TMGChangePayPwdViewController.h"
#import "TMGACResetPwdViewController.h"
@interface TMGAccountSafeViewController ()
@property(nonatomic, strong) NSArray  <STTableEasyModel*>                   *dataSouce;
@end

@implementation TMGAccountSafeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"账号安全";
    [self reloadData];
    // Do any additional setup after loading the view.
}

- (void)reloadData{
    
    
    NSArray * sectionOne = @[
                             [[STTableEasyModel alloc] initWithTextString:@"修改登录密码"
                                                             detailString:[STUserManger defult].loginUser.mobile],
                             [[STTableEasyModel alloc] initWithTextString:@"修改交易密码" detailString:@""],
                             [[STTableEasyModel alloc] initWithTextString:@"电子签名证书" detailString:@"未申请"]];
    

    self.dataSouce = sectionOne;
    [self.tableView reloadData];
}
#pragma --mark UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1 ;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.dataSouce.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 44;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 10;
}
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [UIView new];
}
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return [UIView new];
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * reuseIdentifier =  @"cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentifier];
        
    }
    cell.textLabel.textColor = UIColorFromRGBA(0x333333);
    cell.textLabel.font = [UIFont systemFontOfSize:14];
    cell.detailTextLabel.font = [UIFont systemFontOfSize:13];
    cell.detailTextLabel.textColor = UIColorFromRGBA(0x999999);
    
    STTableEasyModel * model = self.dataSouce[indexPath.row];
    cell.textLabel.text = model.textString;
    cell.detailTextLabel.text = model.detailString;
    if (model.accessoryView) {
        cell.accessoryView = model.accessoryView;
    }else{
        cell.accessoryType = model.accessoryType;
    }
    return cell;
}
#pragma --mark UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    STTableEasyModel * model = self.dataSouce[indexPath.row];
    if ([model.textString isEqualToString:@"修改登录密码"]) {
        [self.navigationController pushViewController:[TMGACResetPwdViewController new] animated:YES];
    }
    if ([model.textString isEqualToString:@"修改交易密码"]) {
        [self.navigationController pushViewController:[TMGChangePayPwdViewController new] animated:YES];
    }
    if ([model.textString isEqualToString:@"电子签名证书"]) {
       [self.navigationController pushViewController:[TMGEleSignViewController new] animated:YES];
    }

    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
}


@end
